package com.example.bingobox.service;

import android.accessibilityservice.AccessibilityService;
import android.app.ActivityManager;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Handler;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityWindowInfo;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import android.widget.Toast;
import android.media.session.PlaybackState;
import android.view.accessibility.AccessibilityNodeInfo;
import android.view.KeyEvent;
import java.util.Arrays;
import android.app.NotificationManager;
import android.app.Notification;
import androidx.core.app.NotificationCompat;
import android.app.NotificationChannel;

public abstract class MyAccessibilityService extends AccessibilityService {
    private String currentPackage;
    private Handler handler = new Handler();
    private boolean isTimerActive = false;

    @Override
    public void onInterrupt() {
        // 服务中断时的处理
        try {
            // 显示服务中断通知
            NotificationManager notificationManager = 
                (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
            
            NotificationCompat.Builder builder = new NotificationCompat.Builder(this, "service_status")
                .setSmallIcon(android.R.drawable.ic_dialog_alert)
                .setContentTitle("服务已中断")
                .setContentText("应用控制服务已中断，请重新启动")
                .setPriority(NotificationCompat.PRIORITY_HIGH)
                .setAutoCancel(true);

            
        } catch (Exception e) {
        }
    }

    // 添加显示通知的辅助方法
    private void showNotification(String title, String content, int importance) {
        NotificationManager notificationManager = 
            (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
        
        // 创建通知
        NotificationCompat.Builder builder = new NotificationCompat.Builder(this, "app_control")
            .setSmallIcon(android.R.drawable.ic_dialog_alert)
            .setContentTitle(title)
            .setContentText(content)
            .setPriority(NotificationCompat.PRIORITY_HIGH)
            .setAutoCancel(true);

    }
} 